﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
//不能创建临时变量（第三个变量），实现两个整数变量的交换。
int main()
{
	int a = 3;
	int b = 2;
	/*a = a + b;
	b = a - b;
	a = a - b;*///不适合数值过大
	a = a ^ b;
	b = a ^ b;
	a = a ^ b;

	return 0;
}

//法1
//int count_bit_one(unsigned int n)
//{
//	int count = 0;
//	while (n)
//	{
//		if (n % 2 == 0)
//				count++;
//			n = n / 2;
//	}
//}
//法2
//int count_bit_one(unsigned int n)
//{
//	int count = 0;
//	int i = 0
//	for (i = 0; i < 32; i++)
//		{
//
//	}
//}
//法三
int count_bit_one(unsigned int n)
{
	int count = 0;
	while (n)
	{
		n = n & (n - 1);
		count++;
	}
}


//编写代码实现：求⼀个整数存储在内存中的⼆进制中1的个数。
int main1()
{
	int num = 0;
	scanf("%d", &num);
	int ret = count_bit_one(num);
	printf("%d", ret);
	return 0;
}

//写一个代码，判断n是否2的次方数

//编写代码将13⼆进制序列的第5位修改为1，然后再改回0
int main2()
{
	int a = 13;
	int n = 5;
	a = a | (1 << (n - 1));
	printf("%d\n", a);

	a &= ~(a << (n - 1));
	printf("%d\n", a);
	return 0;
}

//学生类型
struct Student//图纸
{
	//成员变量
	char name[20];
	int age;
	float score;
}s4, s5, s6;//全局变量
//变量列表
struct Student s3;//全局变量

struct Point
{
	int x;
	int y;
};

struct S
{
	char ch;
	struct Point p;
	int arr[10];
	double d;
};
int main()
{
	int a = 0;
	struct Student s1 = {"翠花",20,98.0};//房子  局部变量
	struct Student s2 = {"旺财",18,69.8};//房子
	struct S s = { 'a',{1,2},{1,2,3,4,5,6,7,8,9,10},3.14 };

	printf("%c\n", s.ch);
	printf("%d %d\n", s.p.x, s.p.y);
	printf("%d\n", s.arr[0]);
	//左边结构体变量.结构体成员名
	//->依赖指针
}